<template>
    <div>
        <p>用户名：<input type="text" v-model="username"></p>
        <p>密码：<input type="text" v-model="password"></p>
        <p><input type="button" value="注册" @click="apps()"></p>
        <p><input type="button" value="用户信息" @click="yes_token()"></p>


    </div>
</template>

<script>
import axios from "axios" 
export default {
    name:"registerjwt",
    data(){
        return{
            username:"",
            password:"",
        }
    },
    methods:{
        apps(){
            var data= new FormData()
            data.append("username",this.username)
            data.append("password",this.password)
            axios({
                url:"http://127.0.0.1:8000/users/register/",
                method:"POST",
                data:data
            }).then(res=>{
                console.log(res.data)
                sessionStorage.setItem("jwt_token",res.data.token)
                console.log("jwt_token",sessionStorage.getItem("jwt_token"))
            })
        },
        yes_token(){
            this.$router.push({path:"/loginjwt"})
        }
    }
}
</script>

